<script src="/js/jquery.datatables.min.js"></script>
<script src="/js/chosen.jquery.min.js"></script>
<script>
	$(document).ready(function() {
    $('#table2').dataTable({
      	"bPaginate": false,
        "bLengthChange": false,
        "bFilter": true,
        "bSort": true,
        "bInfo": false,
        "bAutoWidth": false
    });
    
  });
</script>
 <link href="/css/jquery.datatables.css" rel="stylesheet">
<!--thong bao-->
	<?php echo $this->Session->flash();?>
<!--thong bao-->
<div class="table-responsive">
	<a class="btn btn-pink" href="/categories/add">Chuyên mục mới</a>
	<table class="table" id="table2">
		<thead>
			<tr>
				<th>Stt</th>
				<th>Tên chuyên mục</th>
				<th>Chủ đề</th>
				<th>Chỉnh sửa</th>
			</tr>
		</thead>
		<tbody>
			<?php $i = 1; foreach($data as $item){?>
				<tr>
					<td><?php echo $i ?></td>
					<td><?php echo $item['Category']['name']?></td>
					<td><?php echo $item['Topic']['name']?></td>
					<td>
						<a href="/Categories/edit/<?php echo $item['Category']['id'] ?>"><i class="fa fa-edit"></i></a>
						<a href="/Categories/delete/<?php echo $item['Category']['id'] ?>" onclick="if (confirm('Bạn có muốn xóa?')) { return true; } return false;"><i class="fa  fa-times-circle"></i></a>
					</td>
				</tr>
				
			<?php $i++;} ?>
		</tbody>
	</table>
	<?php echo $this->element('pagination', array('Paginator' => $this->Paginator));?>
</div><!-- table-responsive -->

